<template>
  <div>
    <el-row>
      <el-col
        :span="8"
        v-for="(el, index) in list"
        :key="el.id"
        :offset="index > 0 ? 2 : 0"
        style="width:200px;height:500px;margin-left:150px"
      >
        <el-card
          :body-style="{ padding: '0px' }"
          style="cursor: pointer;width:300px;height:420px"
          @click.native=godetail(el.id)
        >
          <img
            :src="el.src"
            class="image"
          >
          <div style="padding: 14px;">
            <div class="price">￥{{Number(el.price).toFixed(2)}}</div>
            <div class="name">{{el.name}}</div>
            <div class="bottom clearfix">
              <span class="school">{{el.place}}</span>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>
<script>
export default {
  data: () => ({
    list: []
  }),
  async created() {
    const res = await this.$http.beauty()
    console.log(res.message)
    this.list = res.message
  },
  methods: {
    godetail(id) {
      console.log(id)
      this.$router.push('/goodsdetail/' + id)
    }
  }
}
</script>
<style lang="scss" scoped>
.bottom {
  margin-top: 13px;
  line-height: 12px;
}

.button {
  padding: 0;
  float: right;
}

.image {
  width: 100%;
  display: block;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both;
}
.price {
  font-size: 22px;
  color: red;
}
.name {
  font-size: 14px;
  height: 40px;
  overflow: hidden;
}
.school {
  font-size: 13px;
  color: #999;
}
</style>
